<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增物资')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-dept-add">
        <input id="treeId" name="parentId" type="hidden" value="1"/>
        <input id="planId" name="planId" th:value="${planId}" type="hidden"/>
        <input id="stageId" name="stageId" th:value="${stageId}" type="hidden"/>
        <input name="inputCn" id="inputCn" type="hidden">
        <input name="input" id="input" type="hidden">

        <div class="form-group">
            <label class="col-sm-3 control-label ">农资名称：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" type="text" onclick="selectMeterialTree()" id="treeName"
                           readonly="true">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">数量：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="inputCount"  required onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">单位：</label>
            <div class="col-sm-8">
                <select name="inputUnit" class="form-control m-b" th:with="type=${@dict.getType('normal_unit')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">完成时间：</label>
            <div class="col-sm-8">
                <input id="createTime" required data-format="yyyy-MM-dd" name="createTime"
                       th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd')}" class="form-control"
                       type="text" th:class="time-input">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" rows="4" class="form-control" type="text"></textarea>
            </div>
        </div>


    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "system/meterial";

    $("#form-dept-add").validate({
        onkeyup: false,
        rules: {
            orderNum: {
                digits: true
            },
            email: {
                email: true,
            },
            phone: {
                isPhone: true,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(ctx + "system/ncWorkLog/addNongZiSave", $('#form-dept-add').serialize(),function () {
                parent.reload();
            });
        }
    }

    /*蔬菜管理-新增-选择父蔬菜树*/
    function selectMeterialTree() {
        var options = {
            title: '农资选择',
            width: "380",
            url: prefix + "/selectMeterialTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = layer.getChildFrame('body', index);
        $("#input").val(body.find('#treeId').val());
        $("#inputCn").val(body.find('#treeName').val());
        $("#treeName").val(body.find('#treeName').val());
        layer.close(index);
    }
</script>
</body>
</html>
